
import {lsHttp} from "../utils/lshttp";
import {useCommonInfoStore} from "../stores/modules/commonInfo";
import {getDayDate} from "../utils/date";
// 获取用户信息
export const getUserInfoAPI = () => {
    return lsHttp({
        url: '/api/user/info',
        method: 'POST',
    }, false)
}

// 绑定推广人
export const getBindPidAPI = (parent_id, source) => {
    const commonInfoStore = useCommonInfoStore()
    return lsHttp({
        url: '/api/user/bindPid',
        method: 'POST',
        data: {
            parent_id,
            source,
        }
    }).finally(() => {
        commonInfoStore.clearId()
    })
}
/**
 * 获取会员充值信息
 */
export const rechargeInfo = () => {
    return lsHttp({
        url: '/api/member/rechargeInfo',
        method: 'POST',
    })
}

// 绑定分销商
export const getBindResellerIdAPI = (reseller_id) => {
    return lsHttp({
        url: '/api/user/bindResellerId',
        method: 'POST',
        data: {
            reseller_id
        }
    })
}
// 更新头像和昵称
export const updateNicknameAndAvatarAPI = (data) => {
    return lsHttp({
        url: '/api/user/updateNicknameAndAvatar',
        method: 'POST',
        data: data
    })
}
// 获取会员
export const giveMemberAPI = () => {
    return lsHttp({
        url: '/api/member/giveMember',
        method: 'POST',
    })
}
// 获取是否开启微信登录钱包等功能
export const wechatLoginSwitchAPI = (version) => {
    return lsHttp({
        url: '/api/common/wechatLoginSwitch',
        method: 'POST',
        data: {version}
    })
}
// 获取是否开启微信登录钱包等功能
export const updateConfigAPI = () => {
    return lsHttp({
        url: '/api/config/appConfig',
        method: 'POST'
    })
}
// 获取个人中心菜单
export const getNavUserAPI = () => {
    return lsHttp({
        url: '/api/nav/user',
        method: 'POST',
    })
}
// 获取我的会员信息
export const getMemberAPI = () => {
    return lsHttp({
        url: '/api/member/info',
        method: 'POST',
    })
}
// 获取我的会员信息
export const getMemberAgreementAPI = () => {
    return lsHttp({
        url: '/api/common/memberAgreement',
        method: 'POST',
    })
}
// 购买会员
export const buyMemberAPI = (pay_type, member_type_id) => {
    return lsHttp({
        url: '/api/member/recharge',
        method: 'POST',
        data: {
            pay_type,
            member_type_id
        }
    })
}
// 充值金币
export const buyGoldAPI = (pay_type, gold_type) => {
    return lsHttp({
        url: '/api/discount/recharge',
        method: 'POST',
        data: {
            pay_type,
            gold_type
        }
    })
}
// 获取美团链接
export const getMtUrlAPI = () => {
    return lsHttp({
        url: '/api/discount/getMtUrl',
        method: 'POST',
    })
}
// 保存修改美团链接
export const saveMtUrlAPI = (discount_url) => {
    return lsHttp({
        url: '/api/discount/saveMtUrl',
        method: 'POST',
        data: {
            discount_url
        }
    })
}
// 领取优惠券
export const receiveDiscountAPI = (discount_url, coupon_type, title) => {
    return lsHttp({
        url: '/api/discount/receiveDiscount',
        method: 'POST',
        data: {
            discount_url,
            coupon_type,
            title
        }
    })
}
// 领取优惠券失败回调
export const failDiscountAPI = (discount_redeem_id) => {
    return lsHttp({
        url: '/api/discount/failDiscount',
        method: 'POST',
        data: {
            discount_redeem_id
        }
    })
}
// 领取优惠券失败回调
export const recodeLogAPI = (data) => {
    return lsHttp({
        url: '/api/discount/recodeLog',
        method: 'POST',
        data: data
    }, false)
}

// 领取会员奖励
export const getAwardAPI = () => {
    return lsHttp({
        url: '/api/member/getAward',
        method: 'POST'
    })
}
// 获取优惠配置
export const discountConfigListAPI = () => {
    return lsHttp({
        url: '/api/discount/discountConfigList',
        method: 'POST'
    })
}

// 解除风控
export const relaxAPI = (url) => {
    return lsHttp({
        url: '/api/discount/relax',
        method: 'POST',
        data: {
            url: url
        }
    })
}

// 会员v1到v5信息获取
export const vipInfoAPI = (pay_type, member_type_id) => {
    return lsHttp({
        url: '/api/member/newInfo',
        method: 'POST'
    })
}
// 获取我的金币数
export const getConfigAPI = () => {
    return lsHttp({
        url: '/api/signIn/config',
        method: 'POST',
    }, false)
}

// 看视频获取金币
export const lookVideoAPI = () => {
    return lsHttp({
        url: '/api/signIn/lookVideo',
        method: 'POST',
    })
}

// 获取免费领取会员列表
export const getFreeVipAPI = () => {
    return lsHttp({
        url: '/api/member/free',
        method: 'POST',
    })
}
// 我得推广二维码
export const getServiceQrcodeAPI = () => {
    return lsHttp({
        url: '/api/user/getServiceQrcode',
        method: 'POST',
    })
}
//领取会员
export const redeemMemberAPI = (member_type) => {
    return lsHttp({
        url: '/api/signIn/redeemMember',
        method: 'POST',
        data: {
            member_type,
        }
    })
}
// 获取金币明细列表
export const getSignInAPI = (page, limit) => {
    return lsHttp({
        url: '/api/signIn/lists',
        method: 'POST',
        data: {
            page,
            limit
        }
    }, false)
}
// 获取金币明细列表
export const getMemberInAPI = (page, limit) => {
    return lsHttp({
        url: '/api/member/lists',
        method: 'POST',
        data: {
            page,
            limit
        }
    }, false)
}
// 获取签到日期
export const getSignInMonthAPI = () => {
    return lsHttp({
        url: '/api/signIn/month',
        method: 'POST',
        data: {
            month: getDayDate()
        }
    })
}
// 补签
export const makeUpSignInAPI = (date) => {
    return lsHttp({
        url: '/api/signIn/makeUpSignIn',
        method: 'POST',
        data: {
            date
        }
    })
}
// 立即签到
export const signInInAPI = () => {
    return lsHttp({
        url: '/api/signIn/signIn',
        method: 'POST',
    })
}
// 余额明细
export const yueDetailAPI = (data) => {
    return lsHttp({
        url: '/api/Wallet/income',
        method: 'POST',
        data: data
    })
}

// 设置提现密码
// cash_password	是	string	提现密码 6位
// re_cash_password	是	string	再次输入提现密码
// code	是	int	操作验证码
export const updateCashPasswordAPI = (cash_password, re_cash_password, code) => {
    return lsHttp({
        url: '/api/user/updateCashPassword',
        method: 'POST',
        data: {
            cash_password,
            re_cash_password,
            code,
        },
    })
}

// 操作验证码
export const handleCodeAPI = () => {
    return lsHttp({
        url: '/api/user/handleCode',
        method: 'POST',
    })
}
// 操作验证码
export const bindTelAPI = (data) => {
    return lsHttp({
        url: '/api/user/bindTel',
        method: 'POST',
        data: data
    })
}
// 操作验证码
export const getImageCodeAPI = (data) => {
    return lsHttp({
        url: '/api/login/imageCode',
        method: 'POST',
        data: data
    })
}
// 更新密码
export const updatePasswordAPI = (data) => {
    return lsHttp({
        url: '/api/user/updatePassword',
        method: 'POST',
        data: data
    })
}
// 更新绑定支付宝账号信息
// alipay_number	是	string	支付宝账号
// real_name	是	string	支付宝姓名
export const saveAlipayInfoAPI = (real_name, alipay_number) => {
    return lsHttp({
        url: '/api/wallet/saveAlipayInfo',
        method: 'POST',
        data: {
            real_name,
            alipay_number,
        },
    })
}

// 余额提现
// cash_password	是	int	提现密码
// amount	是	int	提现金额
export const cashOutAPI = (cash_password, amount, pay_type) => {
    return lsHttp({
        url: '/api/wallet/cashOut',
        method: 'POST',
        data: {
            cash_password,
            amount,
            pay_type: pay_type
        },
    })
}

// 排行榜
export const rankAPI = (type) => {
    return lsHttp({
        url: '/api/distribution/rank',
        method: 'POST',
        data: {
            type
        },
    })
}
// 提现方式
export const cashoutTypeAPI = (type) => {
    return lsHttp({
        url: '/api/common/cashoutType',
        method: 'POST',
        data: {
            type
        },
    })
}
// 公示
export const reportAPI = (type) => {
    return lsHttp({
        url: '/api/distribution/report',
        method: 'POST',
        data: {
            type
        },
    })
}
// 排行榜
export const rankingListAPI = () => {
    return lsHttp({
        url: '/api/user/ranking_list',
        method: 'POST'
    })
}

// 更改手机号
export const changeTelAPI = (data) => {
    return lsHttp({
        url: '/api/user/changeTel',
        method: 'POST',
        data: data
    })
}

// 更改手机号
export const accountCancelAPI = (data) => {
    return lsHttp({
        url: '/api/user/cancel_user',
        method: 'POST',
        data
    })
}

// 更改手机号
export const afbPayAPI = () => {
    return lsHttp({
        url: '/api/login/fbPay',
        method: 'POST'
    })
}

// 更改手机号
export const setMeiTuanTel = (mt_phone) => {
    return lsHttp({
        url: '/api/user/bindMtAccount',
        method: 'POST',
        data: {"mt_phone": mt_phone}
    })
}
// 我的意见反馈
export const userFeedbackAPI = (page, limit) => {
    return lsHttp({
        url: '/api/userFeedback/lists',
        method: 'POST',
        data: {
            page,
            limit
        }
    })
}

// 提交我的意见反馈
export const submitFeedbackAPI = (data) => {
    return lsHttp({
        url: '/api/userFeedback/submitFeedback',
        method: 'POST',
        data: data
    })
}

// 意见反馈详情
export const detailAPI = (id) => {
    return lsHttp({
        url: '/api/userFeedback/detail',
        method: 'POST',
        data: {id}
    })
}

// 获取红包列表数据
export const carRedAPI = (data) => {
    return lsHttp({
        url: '/api/cardRedUser/myCardRed',
        method: 'POST',
        data: data
    })
}


// 领取金币
export const goldRechargeListAPI = () => {
    return lsHttp({
        url: '/api/discount/goldRechargeList',
        method: 'POST'
    })
}

// 获取报名信息
export const getSeedingAPI = (user_id) => {
    return lsHttp({
        url: '/api/seedingActivity/getSeeding',
        method: 'POST',
        data:{
            user_id
        }
    })
}

// 报名种草活动
export const applyAPI = (user_id) => {
    return lsHttp({
        url: '/api/seedingActivity/apply',
        method: 'POST',
        data:{
            user_id
        }
    })
}
// 上传种草活动图片

// 提交审核
export const submitAPI = (data) => {
    return lsHttp({
        url: '/api/seedingActivity/submit',
        method: 'POST',
        data
    })
}

// 提交审核
export const getMarketingXhsAPI = (data) => {
    return lsHttp({
        url: '/api/marketing/getMarketingXhs',
        method: 'POST',
        data
    })
}